package jee.boot.entity.auth;

import com.google.common.collect.Lists;
import jee.boot.common.annotation.Column;
import jee.boot.common.annotation.Table;
import jee.boot.common.annotation.Transient;
import jee.boot.common.basic.interceptor.impl.DefaultPreInsertInterceptor;
import jee.boot.common.basic.interceptor.impl.DefaultPreQueryInterceptor;
import jee.boot.common.basic.interceptor.impl.DefaultPreUpdateInterceptor;
import jee.boot.entity.system.BasicObj;

import java.util.List;

/**
 * 记录集
 */
@Table(name = "mt_rowset")
public class RowSet extends BasicObj<RowSet> {

    private static final long serialVersionUID = 1L;

    /**
     * 模型ID
     */
    @Column(name = "st_model_id",data = {"modelData.id","modelData.no","modelData.code","modelData.name","modelData.desc","modelData.type","modelData.modelTableName"})
    private ModelData modelData;//引用：ST_MODEL
    /**
     * 超类ID
     */
    @Column(name = "st_super_id",data = {"superRowSet.id","superRowSet.no","superRowSet.code","superRowSet.name","superRowSet.desc","superRowSet.type"})
    private RowSet superRowSet;//引用：MT_ROWSET
    /**
     * 虚拟标志
     */
    @Column(name = "st_virtual_flag")
    private String virtualFlag;//字典：DIC_SYS_YesNo，用于预定义的不用于业务使用的超类对象

    @Transient
    private List<RowSetItem> itemList= Lists.newArrayList();

    public RowSet() {
    }

    public RowSet(String id) {
        super(id);
    }

    public ModelData getModelData() {
        return modelData;
    }

    public void setModelData(ModelData modelData) {
        this.modelData = modelData;
    }

    public RowSet getSuperRowSet() {
        return superRowSet;
    }

    public void setSuperRowSet(RowSet superRowSet) {
        this.superRowSet = superRowSet;
    }

    public String getVirtualFlag() {
        return virtualFlag;
    }

    public void setVirtualFlag(String virtualFlag) {
        this.virtualFlag = virtualFlag;
    }

    public List<RowSetItem> getItemList() {
        return itemList;
    }

    public void setItemList(List<RowSetItem> itemList) {
        this.itemList = itemList;
    }
    @Override
    public void preInsert() {
        new DefaultPreInsertInterceptor().execute(this);
    }
    @Override
    public void preUpdate() {
        new DefaultPreUpdateInterceptor().execute(this);
    }
    @Override
    public void preQuery() {
        new DefaultPreQueryInterceptor().execute(this);
    }
}
